{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 数据分析期末项目"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 导入模块\n",
    "import requests\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: pyecharts in c:\\programdata\\anaconda3\\lib\\site-packages (1.9.0)\n",
      "Requirement already satisfied: simplejson in c:\\programdata\\anaconda3\\lib\\site-packages (from pyecharts) (3.17.2)\n",
      "Requirement already satisfied: jinja2 in c:\\programdata\\anaconda3\\lib\\site-packages (from pyecharts) (2.11.2)\n",
      "Requirement already satisfied: prettytable in c:\\programdata\\anaconda3\\lib\\site-packages (from pyecharts) (2.1.0)\n",
      "Requirement already satisfied: MarkupSafe>=0.23 in c:\\programdata\\anaconda3\\lib\\site-packages (from jinja2->pyecharts) (1.1.1)\n",
      "Requirement already satisfied: wcwidth in c:\\programdata\\anaconda3\\lib\\site-packages (from prettytable->pyecharts) (0.2.5)\n",
      "Note: you may need to restart the kernel to use updated packages.\n"
     ]
    }
   ],
   "source": [
    "pip install pyecharts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 导入数据集\n",
    "中国电影网电影 = pd.read_csv(\"中国电影网电影_data.csv\",encoding = \"utf8\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>电影名</th>\n",
       "      <th>累计票房</th>\n",
       "      <th>导演名称</th>\n",
       "      <th>演员</th>\n",
       "      <th>时间</th>\n",
       "      <th>国家及地区</th>\n",
       "      <th>发行公司</th>\n",
       "      <th>类型</th>\n",
       "      <th>链接</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>让子弹飞（2010）\\nLet The Bullets Fly\\n\\n</td>\n",
       "      <td>累计票房65355.3万</td>\n",
       "      <td>姜文 Wen Jiang\\n\\n</td>\n",
       "      <td>周润发 Yun-Fat Chow 葛优 You Ge 陈坤 Kun Chen 刘嘉玲 Car...</td>\n",
       "      <td>2010-12-16（中国）</td>\n",
       "      <td>中国/中国香港</td>\n",
       "      <td>中国电影集团公司</td>\n",
       "      <td>喜剧/动作</td>\n",
       "      <td>http://www.cbooo.cn/m/573439</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>唐山大地震（2010）\\nAfter Shock\\n\\n</td>\n",
       "      <td>累计票房65015.7万</td>\n",
       "      <td>冯小刚 Xiaogang Feng\\n\\n</td>\n",
       "      <td>徐帆 Fan Xu 张静初 Jingchu Zhang 李晨 Chen Li 陈道明 Dao...</td>\n",
       "      <td>2010-7-22（中国）</td>\n",
       "      <td>中国/中国香港</td>\n",
       "      <td>华谊兄弟传媒股份有限公司</td>\n",
       "      <td>剧情/亲情/灾难</td>\n",
       "      <td>http://www.cbooo.cn/m/566405</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>非诚勿扰2（2010）\\nIf You Are The One 2\\n\\n</td>\n",
       "      <td>累计票房47159.2万</td>\n",
       "      <td>冯小刚 Xiaogang Feng\\n\\n</td>\n",
       "      <td>葛优 You Ge 舒淇 Hsu Chi 孙红雷 Honglei Sun 姚晨 Chen Y...</td>\n",
       "      <td>2010-12-22（中国）</td>\n",
       "      <td>中国/中国香港</td>\n",
       "      <td>华谊兄弟传媒股份有限公司</td>\n",
       "      <td>爱情/喜剧</td>\n",
       "      <td>http://www.cbooo.cn/m/588459</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>狄仁杰之通天帝国（2010）\\nDetective Dee and the Mystery ...</td>\n",
       "      <td>累计票房28620.3万</td>\n",
       "      <td>徐克 Hark Tsui\\n\\n</td>\n",
       "      <td>刘德华 Andy Lau 李冰冰 Bingbing Li 刘嘉玲 Carina Lau 邓超...</td>\n",
       "      <td>2010-9-29（中国）</td>\n",
       "      <td>中国/中国香港</td>\n",
       "      <td>华谊兄弟传媒股份有限公司</td>\n",
       "      <td>动作/悬疑/古装</td>\n",
       "      <td>http://www.cbooo.cn/m/572692</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>叶问2：宗师传奇（2010）\\nIp Man 2\\n\\n</td>\n",
       "      <td>累计票房23110.5万</td>\n",
       "      <td>叶伟信 Wilson Yip\\n\\n</td>\n",
       "      <td>甄子丹 Donnie Yen 黄晓明 Xiaoming Huang 熊黛林 Lynn Xio...</td>\n",
       "      <td>2010-4-27（中国）</td>\n",
       "      <td>中国/中国香港</td>\n",
       "      <td>中国电影集团公司</td>\n",
       "      <td>动作/剧情</td>\n",
       "      <td>http://www.cbooo.cn/m/572828</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                 电影名          累计票房  \\\n",
       "0                让子弹飞（2010）\\nLet The Bullets Fly\\n\\n  累计票房65355.3万   \n",
       "1                       唐山大地震（2010）\\nAfter Shock\\n\\n  累计票房65015.7万   \n",
       "2              非诚勿扰2（2010）\\nIf You Are The One 2\\n\\n  累计票房47159.2万   \n",
       "3  狄仁杰之通天帝国（2010）\\nDetective Dee and the Mystery ...  累计票房28620.3万   \n",
       "4                       叶问2：宗师传奇（2010）\\nIp Man 2\\n\\n  累计票房23110.5万   \n",
       "\n",
       "                    导演名称                                                 演员  \\\n",
       "0       姜文 Wen Jiang\\n\\n  周润发 Yun-Fat Chow 葛优 You Ge 陈坤 Kun Chen 刘嘉玲 Car...   \n",
       "1  冯小刚 Xiaogang Feng\\n\\n  徐帆 Fan Xu 张静初 Jingchu Zhang 李晨 Chen Li 陈道明 Dao...   \n",
       "2  冯小刚 Xiaogang Feng\\n\\n  葛优 You Ge 舒淇 Hsu Chi 孙红雷 Honglei Sun 姚晨 Chen Y...   \n",
       "3       徐克 Hark Tsui\\n\\n  刘德华 Andy Lau 李冰冰 Bingbing Li 刘嘉玲 Carina Lau 邓超...   \n",
       "4     叶伟信 Wilson Yip\\n\\n  甄子丹 Donnie Yen 黄晓明 Xiaoming Huang 熊黛林 Lynn Xio...   \n",
       "\n",
       "               时间    国家及地区          发行公司        类型  \\\n",
       "0  2010-12-16（中国）  中国/中国香港      中国电影集团公司     喜剧/动作   \n",
       "1   2010-7-22（中国）  中国/中国香港  华谊兄弟传媒股份有限公司  剧情/亲情/灾难   \n",
       "2  2010-12-22（中国）  中国/中国香港  华谊兄弟传媒股份有限公司     爱情/喜剧   \n",
       "3   2010-9-29（中国）  中国/中国香港  华谊兄弟传媒股份有限公司  动作/悬疑/古装   \n",
       "4   2010-4-27（中国）  中国/中国香港      中国电影集团公司     动作/剧情   \n",
       "\n",
       "                             链接  \n",
       "0  http://www.cbooo.cn/m/573439  \n",
       "1  http://www.cbooo.cn/m/566405  \n",
       "2  http://www.cbooo.cn/m/588459  \n",
       "3  http://www.cbooo.cn/m/572692  \n",
       "4  http://www.cbooo.cn/m/572828  "
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 查看数据\n",
    "中国电影网电影.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据清洗"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>电影名称</th>\n",
       "      <th>票房/万</th>\n",
       "      <th>导演</th>\n",
       "      <th>主演</th>\n",
       "      <th>上映时间</th>\n",
       "      <th>发行地区</th>\n",
       "      <th>发行公司</th>\n",
       "      <th>主要类型</th>\n",
       "      <th>链接</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>让子弹飞（2010）\\nLet The Bullets Fly\\n\\n</td>\n",
       "      <td>累计票房65355.3万</td>\n",
       "      <td>姜文 Wen Jiang\\n\\n</td>\n",
       "      <td>周润发 Yun-Fat Chow 葛优 You Ge 陈坤 Kun Chen 刘嘉玲 Car...</td>\n",
       "      <td>2010-12-16（中国）</td>\n",
       "      <td>中国/中国香港</td>\n",
       "      <td>中国电影集团公司</td>\n",
       "      <td>喜剧/动作</td>\n",
       "      <td>http://www.cbooo.cn/m/573439</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>唐山大地震（2010）\\nAfter Shock\\n\\n</td>\n",
       "      <td>累计票房65015.7万</td>\n",
       "      <td>冯小刚 Xiaogang Feng\\n\\n</td>\n",
       "      <td>徐帆 Fan Xu 张静初 Jingchu Zhang 李晨 Chen Li 陈道明 Dao...</td>\n",
       "      <td>2010-7-22（中国）</td>\n",
       "      <td>中国/中国香港</td>\n",
       "      <td>华谊兄弟传媒股份有限公司</td>\n",
       "      <td>剧情/亲情/灾难</td>\n",
       "      <td>http://www.cbooo.cn/m/566405</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>非诚勿扰2（2010）\\nIf You Are The One 2\\n\\n</td>\n",
       "      <td>累计票房47159.2万</td>\n",
       "      <td>冯小刚 Xiaogang Feng\\n\\n</td>\n",
       "      <td>葛优 You Ge 舒淇 Hsu Chi 孙红雷 Honglei Sun 姚晨 Chen Y...</td>\n",
       "      <td>2010-12-22（中国）</td>\n",
       "      <td>中国/中国香港</td>\n",
       "      <td>华谊兄弟传媒股份有限公司</td>\n",
       "      <td>爱情/喜剧</td>\n",
       "      <td>http://www.cbooo.cn/m/588459</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>狄仁杰之通天帝国（2010）\\nDetective Dee and the Mystery ...</td>\n",
       "      <td>累计票房28620.3万</td>\n",
       "      <td>徐克 Hark Tsui\\n\\n</td>\n",
       "      <td>刘德华 Andy Lau 李冰冰 Bingbing Li 刘嘉玲 Carina Lau 邓超...</td>\n",
       "      <td>2010-9-29（中国）</td>\n",
       "      <td>中国/中国香港</td>\n",
       "      <td>华谊兄弟传媒股份有限公司</td>\n",
       "      <td>动作/悬疑/古装</td>\n",
       "      <td>http://www.cbooo.cn/m/572692</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>叶问2：宗师传奇（2010）\\nIp Man 2\\n\\n</td>\n",
       "      <td>累计票房23110.5万</td>\n",
       "      <td>叶伟信 Wilson Yip\\n\\n</td>\n",
       "      <td>甄子丹 Donnie Yen 黄晓明 Xiaoming Huang 熊黛林 Lynn Xio...</td>\n",
       "      <td>2010-4-27（中国）</td>\n",
       "      <td>中国/中国香港</td>\n",
       "      <td>中国电影集团公司</td>\n",
       "      <td>动作/剧情</td>\n",
       "      <td>http://www.cbooo.cn/m/572828</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                电影名称          票房/万  \\\n",
       "0                让子弹飞（2010）\\nLet The Bullets Fly\\n\\n  累计票房65355.3万   \n",
       "1                       唐山大地震（2010）\\nAfter Shock\\n\\n  累计票房65015.7万   \n",
       "2              非诚勿扰2（2010）\\nIf You Are The One 2\\n\\n  累计票房47159.2万   \n",
       "3  狄仁杰之通天帝国（2010）\\nDetective Dee and the Mystery ...  累计票房28620.3万   \n",
       "4                       叶问2：宗师传奇（2010）\\nIp Man 2\\n\\n  累计票房23110.5万   \n",
       "\n",
       "                      导演                                                 主演  \\\n",
       "0       姜文 Wen Jiang\\n\\n  周润发 Yun-Fat Chow 葛优 You Ge 陈坤 Kun Chen 刘嘉玲 Car...   \n",
       "1  冯小刚 Xiaogang Feng\\n\\n  徐帆 Fan Xu 张静初 Jingchu Zhang 李晨 Chen Li 陈道明 Dao...   \n",
       "2  冯小刚 Xiaogang Feng\\n\\n  葛优 You Ge 舒淇 Hsu Chi 孙红雷 Honglei Sun 姚晨 Chen Y...   \n",
       "3       徐克 Hark Tsui\\n\\n  刘德华 Andy Lau 李冰冰 Bingbing Li 刘嘉玲 Carina Lau 邓超...   \n",
       "4     叶伟信 Wilson Yip\\n\\n  甄子丹 Donnie Yen 黄晓明 Xiaoming Huang 熊黛林 Lynn Xio...   \n",
       "\n",
       "             上映时间     发行地区          发行公司      主要类型  \\\n",
       "0  2010-12-16（中国）  中国/中国香港      中国电影集团公司     喜剧/动作   \n",
       "1   2010-7-22（中国）  中国/中国香港  华谊兄弟传媒股份有限公司  剧情/亲情/灾难   \n",
       "2  2010-12-22（中国）  中国/中国香港  华谊兄弟传媒股份有限公司     爱情/喜剧   \n",
       "3   2010-9-29（中国）  中国/中国香港  华谊兄弟传媒股份有限公司  动作/悬疑/古装   \n",
       "4   2010-4-27（中国）  中国/中国香港      中国电影集团公司     动作/剧情   \n",
       "\n",
       "                             链接  \n",
       "0  http://www.cbooo.cn/m/573439  \n",
       "1  http://www.cbooo.cn/m/566405  \n",
       "2  http://www.cbooo.cn/m/588459  \n",
       "3  http://www.cbooo.cn/m/572692  \n",
       "4  http://www.cbooo.cn/m/572828  "
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 队列名进行重命名\n",
    "中国电影网电影.columns = [x\n",
    "                   .replace(\"电影名\",\"电影名称\")\\\n",
    "                   .replace(\"累计票房\",\"票房/万\")\\\n",
    "                   .replace(\"导演名称\",\"导演\")\\\n",
    "                   .replace(\"演员\",\"主演\")\\\n",
    "                   .replace(\"时间\",\"上映时间\")\\\n",
    "                   .replace(\"国家及地区\",\"发行地区\")\\\n",
    "                   .replace(\"类型\",\"主要类型\") for x in 中国电影网电影.columns]\n",
    "中国电影网电影.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0            让子弹飞\n",
       "1           唐山大地震\n",
       "2           非诚勿扰2\n",
       "3        狄仁杰之通天帝国\n",
       "4        叶问2：宗师传奇\n",
       "          ...    \n",
       "3136         麻辣母女\n",
       "3137         寻找尘微\n",
       "3138    火线追击之死亡地带\n",
       "3139        雷横与朱仝\n",
       "3140    火线追凶之突然死亡\n",
       "Name: 0, Length: 3141, dtype: object"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "中国电影网电影_电影名称 = 中国电影网电影['电影名称'].str.split('（',expand = True)[0]\n",
    "中国电影网电影_电影名称"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>序号</th>\n",
       "      <th>电影名称</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>让子弹飞</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>唐山大地震</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>非诚勿扰2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>狄仁杰之通天帝国</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>叶问2：宗师传奇</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   序号      电影名称\n",
       "0   0      让子弹飞\n",
       "1   1     唐山大地震\n",
       "2   2     非诚勿扰2\n",
       "3   3  狄仁杰之通天帝国\n",
       "4   4  叶问2：宗师传奇"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dict_电影名称_准备合并 = {\n",
    "    \"序号\":中国电影网电影_电影名称.index,\n",
    "    \"电影名称\":中国电影网电影_电影名称.values\n",
    "}\n",
    "df_电影名称_准备合并=pd.DataFrame(dict_电影名称_准备合并)\n",
    "df_电影名称_准备合并.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0       65355.3\n",
       "1       65015.7\n",
       "2       47159.2\n",
       "3       28620.3\n",
       "4       23110.5\n",
       "         ...   \n",
       "3136        NaN\n",
       "3137        NaN\n",
       "3138        NaN\n",
       "3139        NaN\n",
       "3140        NaN\n",
       "Name: 0, Length: 3141, dtype: float64"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "中国电影网电影_票房 = 中国电影网电影['票房/万'].str.split('房',expand = True)[1].str.split('万',expand = True)[0].apply(pd.to_numeric, errors = 'ignore')\n",
    "中国电影网电影_票房"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>序号</th>\n",
       "      <th>票房/万</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>65355.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>65015.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>47159.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>28620.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>23110.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   序号     票房/万\n",
       "0   0  65355.3\n",
       "1   1  65015.7\n",
       "2   2  47159.2\n",
       "3   3  28620.3\n",
       "4   4  23110.5"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dict_票房_准备合并 = {\n",
    "    \"序号\":中国电影网电影_票房.index,\n",
    "    \"票房/万\":中国电影网电影_票房.values,\n",
    "}\n",
    "df_票房_准备合并=pd.DataFrame(dict_票房_准备合并)\n",
    "df_票房_准备合并.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0            姜文\n",
       "1           冯小刚\n",
       "2           冯小刚\n",
       "3            徐克\n",
       "4           叶伟信\n",
       "         ...   \n",
       "3136         曹伟\n",
       "3137         沈东\n",
       "3138    Mingkai\n",
       "3139        黄祖权\n",
       "3140    Mingkai\n",
       "Name: 0, Length: 3141, dtype: object"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "中国电影网电影_导演 = 中国电影网电影['导演'].str.split(' ',expand = True)[0]\n",
    "中国电影网电影_导演"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>序号</th>\n",
       "      <th>导演</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>姜文</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>冯小刚</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>冯小刚</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>徐克</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>叶伟信</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   序号   导演\n",
       "0   0   姜文\n",
       "1   1  冯小刚\n",
       "2   2  冯小刚\n",
       "3   3   徐克\n",
       "4   4  叶伟信"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dict_导演_准备合并 = {\n",
    "    \"序号\":中国电影网电影_导演.index,\n",
    "    \"导演\":中国电影网电影_导演.values\n",
    "}\n",
    "df_导演_准备合并=pd.DataFrame(dict_导演_准备合并)\n",
    "df_导演_准备合并.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0       周润发\n",
       "1        徐帆\n",
       "2        葛优\n",
       "3       刘德华\n",
       "4       甄子丹\n",
       "       ... \n",
       "3136     石林\n",
       "3137     倪萍\n",
       "3138    钟汉良\n",
       "3139    焦恩俊\n",
       "3140    钟汉良\n",
       "Name: 0, Length: 3141, dtype: object"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "中国电影网电影_主演 = 中国电影网电影['主演'].str.split(' ',expand = True)[0]\n",
    "中国电影网电影_主演"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>序号</th>\n",
       "      <th>主演</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>周润发</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>徐帆</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>葛优</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>刘德华</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>甄子丹</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   序号   主演\n",
       "0   0  周润发\n",
       "1   1   徐帆\n",
       "2   2   葛优\n",
       "3   3  刘德华\n",
       "4   4  甄子丹"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dict_主演_准备合并 = {\n",
    "    \"序号\":中国电影网电影_主演.index,\n",
    "    \"主演\":中国电影网电影_主演.values\n",
    "}\n",
    "df_主演_准备合并=pd.DataFrame(dict_主演_准备合并)\n",
    "df_主演_准备合并.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0       2010-12-16\n",
       "1        2010-7-22\n",
       "2       2010-12-22\n",
       "3        2010-9-29\n",
       "4        2010-4-27\n",
       "           ...    \n",
       "3136     2009-3-31\n",
       "3137     2009-6-19\n",
       "3138      2009-7-2\n",
       "3139     2009-3-26\n",
       "3140      2009-1-1\n",
       "Name: 0, Length: 3141, dtype: object"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "中国电影网电影_上映时间 = 中国电影网电影['上映时间'].str.split('（',expand = True)[0]\n",
    "中国电影网电影_上映时间"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>序号</th>\n",
       "      <th>上映时间</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>2010-12-16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>2010-7-22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>2010-12-22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>2010-9-29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>2010-4-27</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   序号        上映时间\n",
       "0   0  2010-12-16\n",
       "1   1   2010-7-22\n",
       "2   2  2010-12-22\n",
       "3   3   2010-9-29\n",
       "4   4   2010-4-27"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dict_上映时间_准备合并 = {\n",
    "    \"序号\":中国电影网电影_上映时间.index,\n",
    "    \"上映时间\":中国电影网电影_上映时间.values\n",
    "}\n",
    "df_上映时间_准备合并=pd.DataFrame(dict_上映时间_准备合并)\n",
    "df_上映时间_准备合并.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0       2010\n",
       "1       2010\n",
       "2       2010\n",
       "3       2010\n",
       "4       2010\n",
       "        ... \n",
       "3136    2009\n",
       "3137    2009\n",
       "3138    2009\n",
       "3139    2009\n",
       "3140    2009\n",
       "Name: 0, Length: 3141, dtype: object"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "中国电影网电影_上映年份 = 中国电影网电影['上映时间'].str.split('（',expand = True)[0].str.split('-',expand = True)[0]\n",
    "中国电影网电影_上映年份"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>序号</th>\n",
       "      <th>上映年份</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>2010</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>2010</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>2010</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>2010</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>2010</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   序号  上映年份\n",
       "0   0  2010\n",
       "1   1  2010\n",
       "2   2  2010\n",
       "3   3  2010\n",
       "4   4  2010"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dict_上映年份_准备合并 = {\n",
    "    \"序号\":中国电影网电影_上映年份.index,\n",
    "    \"上映年份\":中国电影网电影_上映年份.values\n",
    "}\n",
    "df_上映年份_准备合并=pd.DataFrame(dict_上映年份_准备合并)\n",
    "df_上映年份_准备合并.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0       12\n",
       "1        7\n",
       "2       12\n",
       "3        9\n",
       "4        4\n",
       "        ..\n",
       "3136     3\n",
       "3137     6\n",
       "3138     7\n",
       "3139     3\n",
       "3140     1\n",
       "Name: 1, Length: 3141, dtype: object"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "中国电影网电影_上映月份 = 中国电影网电影['上映时间'].str.split('（',expand = True)[0].str.split('-',expand = True)[1]\n",
    "中国电影网电影_上映月份"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>序号</th>\n",
       "      <th>上映年份</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>2010</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>2010</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>2010</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>2010</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>2010</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   序号  上映年份\n",
       "0   0  2010\n",
       "1   1  2010\n",
       "2   2  2010\n",
       "3   3  2010\n",
       "4   4  2010"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dict_上映月份_准备合并 = {\n",
    "    \"序号\":中国电影网电影_上映月份.index,\n",
    "    \"上映月份\":中国电影网电影_上映月份.values\n",
    "}\n",
    "df_上映月份_准备合并=pd.DataFrame(dict_上映月份_准备合并)\n",
    "df_上映月份_准备合并dict_上映年份_准备合并 = {\n",
    "    \"序号\":中国电影网电影_上映年份.index,\n",
    "    \"上映年份\":中国电影网电影_上映年份.values\n",
    "}\n",
    "df_上映年份_准备合并=pd.DataFrame(dict_上映年份_准备合并)\n",
    "df_上映年份_准备合并.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0       中国香港\n",
       "1       中国香港\n",
       "2       中国香港\n",
       "3       中国香港\n",
       "4       中国香港\n",
       "        ... \n",
       "3136    None\n",
       "3137    None\n",
       "3138    None\n",
       "3139    None\n",
       "3140    None\n",
       "Name: 1, Length: 3141, dtype: object"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "中国电影网电影_发行地区 = 中国电影网电影['发行地区'].str.split('/',expand = True)[1]\n",
    "中国电影网电影_发行地区"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>序号</th>\n",
       "      <th>发行地区</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>中国香港</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>中国香港</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>中国香港</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>中国香港</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>中国香港</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   序号  发行地区\n",
       "0   0  中国香港\n",
       "1   1  中国香港\n",
       "2   2  中国香港\n",
       "3   3  中国香港\n",
       "4   4  中国香港"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dict_发行地区 = {\n",
    "    \"序号\":中国电影网电影_发行地区.index,\n",
    "    \"发行地区\":中国电影网电影_发行地区.values\n",
    "}\n",
    "df_发行地区=pd.DataFrame(dict_发行地区)\n",
    "df_发行地区.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>序号</th>\n",
       "      <th>发行地区</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>中国香港</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>中国香港</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>中国香港</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>中国香港</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>中国香港</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3136</th>\n",
       "      <td>3136</td>\n",
       "      <td>中国大陆</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3137</th>\n",
       "      <td>3137</td>\n",
       "      <td>中国大陆</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3138</th>\n",
       "      <td>3138</td>\n",
       "      <td>中国大陆</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3139</th>\n",
       "      <td>3139</td>\n",
       "      <td>中国大陆</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3140</th>\n",
       "      <td>3140</td>\n",
       "      <td>中国大陆</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3141 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        序号  发行地区\n",
       "0        0  中国香港\n",
       "1        1  中国香港\n",
       "2        2  中国香港\n",
       "3        3  中国香港\n",
       "4        4  中国香港\n",
       "...    ...   ...\n",
       "3136  3136  中国大陆\n",
       "3137  3137  中国大陆\n",
       "3138  3138  中国大陆\n",
       "3139  3139  中国大陆\n",
       "3140  3140  中国大陆\n",
       "\n",
       "[3141 rows x 2 columns]"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_发行地区_准备合并=df_发行地区.fillna(\"中国大陆\")\n",
    "df_发行地区_准备合并"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0       喜剧\n",
       "1       剧情\n",
       "2       爱情\n",
       "3       动作\n",
       "4       动作\n",
       "        ..\n",
       "3136    喜剧\n",
       "3137    剧情\n",
       "3138    动作\n",
       "3139    剧情\n",
       "3140    动作\n",
       "Name: 0, Length: 3141, dtype: object"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "中国电影网电影_主要类型 = 中国电影网电影['主要类型'].str.split('/',expand = True)[0]\n",
    "中国电影网电影_主要类型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>序号</th>\n",
       "      <th>主要类型</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>喜剧</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>剧情</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>爱情</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>动作</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>动作</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   序号 主要类型\n",
       "0   0   喜剧\n",
       "1   1   剧情\n",
       "2   2   爱情\n",
       "3   3   动作\n",
       "4   4   动作"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dict_主要类型_准备合并 = {\n",
    "    \"序号\":中国电影网电影_主要类型.index,\n",
    "    \"主要类型\":中国电影网电影_主要类型.values\n",
    "}\n",
    "df_主要类型_准备合并=pd.DataFrame(dict_主要类型_准备合并)\n",
    "df_主要类型_准备合并.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 多表合并方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "from functools import reduce"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>序号</th>\n",
       "      <th>上映年份</th>\n",
       "      <th>上映月份</th>\n",
       "      <th>电影名称</th>\n",
       "      <th>票房/万</th>\n",
       "      <th>主要类型</th>\n",
       "      <th>发行地区</th>\n",
       "      <th>导演</th>\n",
       "      <th>主演</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>2010</td>\n",
       "      <td>12</td>\n",
       "      <td>让子弹飞</td>\n",
       "      <td>65355.3</td>\n",
       "      <td>喜剧</td>\n",
       "      <td>中国香港</td>\n",
       "      <td>姜文</td>\n",
       "      <td>周润发</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>2010</td>\n",
       "      <td>7</td>\n",
       "      <td>唐山大地震</td>\n",
       "      <td>65015.7</td>\n",
       "      <td>剧情</td>\n",
       "      <td>中国香港</td>\n",
       "      <td>冯小刚</td>\n",
       "      <td>徐帆</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>2010</td>\n",
       "      <td>12</td>\n",
       "      <td>非诚勿扰2</td>\n",
       "      <td>47159.2</td>\n",
       "      <td>爱情</td>\n",
       "      <td>中国香港</td>\n",
       "      <td>冯小刚</td>\n",
       "      <td>葛优</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>2010</td>\n",
       "      <td>9</td>\n",
       "      <td>狄仁杰之通天帝国</td>\n",
       "      <td>28620.3</td>\n",
       "      <td>动作</td>\n",
       "      <td>中国香港</td>\n",
       "      <td>徐克</td>\n",
       "      <td>刘德华</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>2010</td>\n",
       "      <td>4</td>\n",
       "      <td>叶问2：宗师传奇</td>\n",
       "      <td>23110.5</td>\n",
       "      <td>动作</td>\n",
       "      <td>中国香港</td>\n",
       "      <td>叶伟信</td>\n",
       "      <td>甄子丹</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3136</th>\n",
       "      <td>3136</td>\n",
       "      <td>2009</td>\n",
       "      <td>3</td>\n",
       "      <td>麻辣母女</td>\n",
       "      <td>NaN</td>\n",
       "      <td>喜剧</td>\n",
       "      <td>中国大陆</td>\n",
       "      <td>曹伟</td>\n",
       "      <td>石林</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3137</th>\n",
       "      <td>3137</td>\n",
       "      <td>2009</td>\n",
       "      <td>6</td>\n",
       "      <td>寻找尘微</td>\n",
       "      <td>NaN</td>\n",
       "      <td>剧情</td>\n",
       "      <td>中国大陆</td>\n",
       "      <td>沈东</td>\n",
       "      <td>倪萍</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3138</th>\n",
       "      <td>3138</td>\n",
       "      <td>2009</td>\n",
       "      <td>7</td>\n",
       "      <td>火线追击之死亡地带</td>\n",
       "      <td>NaN</td>\n",
       "      <td>动作</td>\n",
       "      <td>中国大陆</td>\n",
       "      <td>Mingkai</td>\n",
       "      <td>钟汉良</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3139</th>\n",
       "      <td>3139</td>\n",
       "      <td>2009</td>\n",
       "      <td>3</td>\n",
       "      <td>雷横与朱仝</td>\n",
       "      <td>NaN</td>\n",
       "      <td>剧情</td>\n",
       "      <td>中国大陆</td>\n",
       "      <td>黄祖权</td>\n",
       "      <td>焦恩俊</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3140</th>\n",
       "      <td>3140</td>\n",
       "      <td>2009</td>\n",
       "      <td>1</td>\n",
       "      <td>火线追凶之突然死亡</td>\n",
       "      <td>NaN</td>\n",
       "      <td>动作</td>\n",
       "      <td>中国大陆</td>\n",
       "      <td>Mingkai</td>\n",
       "      <td>钟汉良</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3141 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        序号  上映年份 上映月份       电影名称     票房/万 主要类型  发行地区       导演   主演\n",
       "0        0  2010   12       让子弹飞  65355.3   喜剧  中国香港       姜文  周润发\n",
       "1        1  2010    7      唐山大地震  65015.7   剧情  中国香港      冯小刚   徐帆\n",
       "2        2  2010   12      非诚勿扰2  47159.2   爱情  中国香港      冯小刚   葛优\n",
       "3        3  2010    9   狄仁杰之通天帝国  28620.3   动作  中国香港       徐克  刘德华\n",
       "4        4  2010    4   叶问2：宗师传奇  23110.5   动作  中国香港      叶伟信  甄子丹\n",
       "...    ...   ...  ...        ...      ...  ...   ...      ...  ...\n",
       "3136  3136  2009    3       麻辣母女      NaN   喜剧  中国大陆       曹伟   石林\n",
       "3137  3137  2009    6       寻找尘微      NaN   剧情  中国大陆       沈东   倪萍\n",
       "3138  3138  2009    7  火线追击之死亡地带      NaN   动作  中国大陆  Mingkai  钟汉良\n",
       "3139  3139  2009    3      雷横与朱仝      NaN   剧情  中国大陆      黄祖权  焦恩俊\n",
       "3140  3140  2009    1  火线追凶之突然死亡      NaN   动作  中国大陆  Mingkai  钟汉良\n",
       "\n",
       "[3141 rows x 9 columns]"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "最终合并 = [df_上映年份_准备合并,df_上映月份_准备合并,df_电影名称_准备合并,df_票房_准备合并,df_主要类型_准备合并,df_发行地区_准备合并,df_导演_准备合并,df_主演_准备合并]\n",
    "中国电影数据 = reduce(lambda left,right: pd.merge(left,right,on='序号'), 最终合并)\n",
    "中国电影数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>序号</th>\n",
       "      <th>上映年份</th>\n",
       "      <th>上映月份</th>\n",
       "      <th>电影名称</th>\n",
       "      <th>票房/万</th>\n",
       "      <th>主要类型</th>\n",
       "      <th>发行地区</th>\n",
       "      <th>导演</th>\n",
       "      <th>主演</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>2010</td>\n",
       "      <td>12</td>\n",
       "      <td>让子弹飞</td>\n",
       "      <td>65355.3</td>\n",
       "      <td>喜剧</td>\n",
       "      <td>中国香港</td>\n",
       "      <td>姜文</td>\n",
       "      <td>周润发</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>2010</td>\n",
       "      <td>7</td>\n",
       "      <td>唐山大地震</td>\n",
       "      <td>65015.7</td>\n",
       "      <td>剧情</td>\n",
       "      <td>中国香港</td>\n",
       "      <td>冯小刚</td>\n",
       "      <td>徐帆</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>2010</td>\n",
       "      <td>12</td>\n",
       "      <td>非诚勿扰2</td>\n",
       "      <td>47159.2</td>\n",
       "      <td>爱情</td>\n",
       "      <td>中国香港</td>\n",
       "      <td>冯小刚</td>\n",
       "      <td>葛优</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>2010</td>\n",
       "      <td>9</td>\n",
       "      <td>狄仁杰之通天帝国</td>\n",
       "      <td>28620.3</td>\n",
       "      <td>动作</td>\n",
       "      <td>中国香港</td>\n",
       "      <td>徐克</td>\n",
       "      <td>刘德华</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>2010</td>\n",
       "      <td>4</td>\n",
       "      <td>叶问2：宗师传奇</td>\n",
       "      <td>23110.5</td>\n",
       "      <td>动作</td>\n",
       "      <td>中国香港</td>\n",
       "      <td>叶伟信</td>\n",
       "      <td>甄子丹</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3107</th>\n",
       "      <td>3107</td>\n",
       "      <td>2009</td>\n",
       "      <td>6</td>\n",
       "      <td>潘作良</td>\n",
       "      <td>6.4</td>\n",
       "      <td>剧情</td>\n",
       "      <td>中国大陆</td>\n",
       "      <td>刘和群</td>\n",
       "      <td>周小斌</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3111</th>\n",
       "      <td>3111</td>\n",
       "      <td>2009</td>\n",
       "      <td>10</td>\n",
       "      <td>大明宫传奇</td>\n",
       "      <td>3.4</td>\n",
       "      <td>爱情</td>\n",
       "      <td>中国大陆</td>\n",
       "      <td>金铁木</td>\n",
       "      <td>宋佳</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3112</th>\n",
       "      <td>3112</td>\n",
       "      <td>2009</td>\n",
       "      <td>2</td>\n",
       "      <td>我的实习生活</td>\n",
       "      <td>2.1</td>\n",
       "      <td>爱情</td>\n",
       "      <td>中国大陆</td>\n",
       "      <td>张骁</td>\n",
       "      <td>沈佳妮</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3113</th>\n",
       "      <td>3113</td>\n",
       "      <td>2009</td>\n",
       "      <td>3</td>\n",
       "      <td>泰山功夫</td>\n",
       "      <td>0.6</td>\n",
       "      <td>动作</td>\n",
       "      <td>中国大陆</td>\n",
       "      <td>陶明喜</td>\n",
       "      <td>许还幻</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3117</th>\n",
       "      <td>3117</td>\n",
       "      <td>2009</td>\n",
       "      <td>12</td>\n",
       "      <td>闻香</td>\n",
       "      <td>0.1</td>\n",
       "      <td>剧情</td>\n",
       "      <td>中国大陆</td>\n",
       "      <td>邓健文</td>\n",
       "      <td>樊锦霖</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2562 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        序号  上映年份 上映月份      电影名称     票房/万 主要类型  发行地区   导演   主演\n",
       "0        0  2010   12      让子弹飞  65355.3   喜剧  中国香港   姜文  周润发\n",
       "1        1  2010    7     唐山大地震  65015.7   剧情  中国香港  冯小刚   徐帆\n",
       "2        2  2010   12     非诚勿扰2  47159.2   爱情  中国香港  冯小刚   葛优\n",
       "3        3  2010    9  狄仁杰之通天帝国  28620.3   动作  中国香港   徐克  刘德华\n",
       "4        4  2010    4  叶问2：宗师传奇  23110.5   动作  中国香港  叶伟信  甄子丹\n",
       "...    ...   ...  ...       ...      ...  ...   ...  ...  ...\n",
       "3107  3107  2009    6       潘作良      6.4   剧情  中国大陆  刘和群  周小斌\n",
       "3111  3111  2009   10     大明宫传奇      3.4   爱情  中国大陆  金铁木   宋佳\n",
       "3112  3112  2009    2    我的实习生活      2.1   爱情  中国大陆   张骁  沈佳妮\n",
       "3113  3113  2009    3      泰山功夫      0.6   动作  中国大陆  陶明喜  许还幻\n",
       "3117  3117  2009   12        闻香      0.1   剧情  中国大陆  邓健文  樊锦霖\n",
       "\n",
       "[2562 rows x 9 columns]"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "最终中国电影数据 = 中国电影数据.dropna(how = 'any')\n",
    "最终中国电影数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "序号        int64\n",
       "上映年份     object\n",
       "上映月份     object\n",
       "电影名称     object\n",
       "票房/万    float64\n",
       "主要类型     object\n",
       "发行地区     object\n",
       "导演       object\n",
       "主演       object\n",
       "dtype: object"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "最终中国电影数据.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2562"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(最终中国电影数据)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据可视化"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 每年电影数量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "上映年份\n",
       "2008     95\n",
       "2009     95\n",
       "2010    130\n",
       "2011    167\n",
       "2012    246\n",
       "2013    267\n",
       "2014    279\n",
       "2015    309\n",
       "2016    359\n",
       "2017    358\n",
       "2018    257\n",
       "Name: 序号, dtype: int64"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "每年电影数量 = 最终中国电影数据.groupby('上映年份')['序号'].count()\n",
    "每年电影数量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'C:\\\\Users\\\\南极有火山\\\\Desktop\\\\Data-final\\\\每年电影数量柱状图.html'"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 每年电影数量柱状图\n",
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Bar\n",
    "from random import randint\n",
    "\n",
    "def bar_series() -> Bar:\n",
    "    每年电影数量 = (\n",
    "        Bar()\n",
    "        .add_xaxis([\"2008\", \"2009\", \"2010\", \"2011\", \"2012\", \"2013\", \"2014\", \"2015\", \"2016\", \"2017\", \"2018\"])\n",
    "        .add_yaxis(\"电影数量\", [95,95,130,167,246,267,279,309,359,358,257])\n",
    "        .set_global_opts(title_opts=opts.TitleOpts(title=\"每年电影数量\",pos_left= '20%',pos_right='50%'))\n",
    "    )\n",
    "    return 每年电影数量\n",
    "bar_series().render_notebook()\n",
    "bar_series().render(\"每年电影数量柱状图.html\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "359"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "每年电影数量.max()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "# plt.figure(figsize=(20,8),dpi=100)\n",
    "# 每年电影数量.plot()\n",
    "# plt.savefig('每年电影数量.png')\n",
    "# plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 历年来电影票房"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "上映年份\n",
       "2008     19.44403\n",
       "2009     29.77501\n",
       "2010     54.25160\n",
       "2011     59.88972\n",
       "2012     82.82228\n",
       "2013    130.92666\n",
       "2014    183.28347\n",
       "2015    290.84039\n",
       "2016    263.27622\n",
       "2017    308.04092\n",
       "2018    309.60264\n",
       "Name: 票房/万, dtype: float64"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "每年电影票房 = 最终中国电影数据.groupby('上映年份')['票房/万'].sum()/10000\n",
    "每年电影票房"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'C:\\\\Users\\\\南极有火山\\\\Desktop\\\\Data-final\\\\历年来电影票房玫瑰图.html'"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 历年来电影票房玫瑰图\n",
    "import pandas as pd\n",
    "from pyecharts.charts import Pie\n",
    "from pyecharts import options as opts\n",
    "\n",
    "color_series = ['#FAE927','#E9E416','#C9DA36','#9ECB3C','#6DBC49', '#37B44E','#3DBA78','#14ADCF','#209AC9','#1E91CA','#2C6BA0']\n",
    "year = [\"2008\",\"2009\",\"2010\",\"2011\",\"2012\",\"2013\",\"2014\",\"2015\",\"2016\",\"2017\",\"2018\"] \n",
    "num = [19,30,54,60,83,131,183,291,263,308,310] # 不保留小数点，数据四舍五入\n",
    "\n",
    "历年来电影票房 = pd.DataFrame({'year': year, 'num': num})\n",
    "历年来电影票房.sort_values(by='num', ascending=False, inplace=True)\n",
    "v = 历年来电影票房['year'].values.tolist()\n",
    "d = 历年来电影票房['num'].values.tolist()\n",
    "# 实例化Pie类\n",
    "pie1 = Pie(init_opts=opts.InitOpts(width='1000px', height='600px'))\n",
    "# 设置颜色\n",
    "pie1.set_colors(color_series)\n",
    "# 添加数据，设置饼图的半径，是否展示成南丁格尔图\n",
    "pie1.add(\"\", [list(z) for z in zip(v, d)],\n",
    "        radius=[\"36%\", \"100%\"],\n",
    "        center=[\"50%\", \"60%\"],\n",
    "        rosetype=\"area\"\n",
    "        )\n",
    "# 设置全局配置项\n",
    "pie1.set_global_opts(title_opts=opts.TitleOpts(title='2008-2018', subtitle='电影票房',\n",
    "                                               title_textstyle_opts=opts.TextStyleOpts(font_size=25,color= '#0085c3'),\n",
    "                                               subtitle_textstyle_opts= opts.TextStyleOpts(font_size=45,color= '#003399'),\n",
    "                                               pos_right= 'center',pos_left= 'center',pos_top= '53%',pos_bottom='center'\n",
    "                                              ),\n",
    "                     legend_opts=opts.LegendOpts(is_show=False),\n",
    "                     toolbox_opts=opts.ToolboxOpts())\n",
    "\n",
    "# 设置系列配置项\n",
    "pie1.set_series_opts(label_opts=opts.LabelOpts(is_show=True, position=\"inside\", font_size=18,\n",
    "                                               formatter=\"{b}:{c}亿\", font_style=\"italic\",\n",
    "                                               font_weight=\"bold\", font_family=\"Microsoft YaHei\"\n",
    "                                               ),\n",
    "                     )\n",
    "# 生成html文档\n",
    "pie1.render('历年来电影票房玫瑰图.html')\n",
    "# pie1.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "# plt.figure(figsize=(20,8),dpi=80)\n",
    "# 历年来电影票房走势.plot()\n",
    "# plt.savefig('历年来电影票房走势.png')\n",
    "# plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 各月份电影数量及票房"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "上映月份\n",
       "1     201\n",
       "10    220\n",
       "11    224\n",
       "12    216\n",
       "2     143\n",
       "3     176\n",
       "4     209\n",
       "5     196\n",
       "6     244\n",
       "7     224\n",
       "8     261\n",
       "9     248\n",
       "Name: 序号, dtype: int64"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "各月份电影数量 = 最终中国电影数据.groupby('上映月份')['序号'].count()\n",
    "各月份电影数量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "上映月份\n",
       "1     163.36483\n",
       "10     34.85055\n",
       "11     50.74244\n",
       "12    261.48898\n",
       "2     251.87073\n",
       "3      45.03340\n",
       "4     116.52168\n",
       "5      40.47147\n",
       "6      88.01853\n",
       "7     310.01081\n",
       "8     130.19659\n",
       "9     239.58293\n",
       "Name: 票房/万, dtype: float64"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "各月份电影票房 = 最终中国电影数据.groupby('上映月份')['票房/万'].sum()/10000\n",
    "各月份电影票房"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'C:\\\\Users\\\\南极有火山\\\\Desktop\\\\Data-final\\\\各月份电影数量及票房雷达图.html'"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 各月份电影数量及票房雷达图\n",
    "import random\n",
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Page, Radar\n",
    "\n",
    "def radar_simple() -> Radar:\n",
    "    各月份电影 = (\n",
    "        Radar()\n",
    "        .add_schema(\n",
    "            # 各项的max_值可以不同\n",
    "            schema=[\n",
    "                opts.RadarIndicatorItem(name='1月份', max_=320),\n",
    "                opts.RadarIndicatorItem(name='2月份', max_=320),\n",
    "                opts.RadarIndicatorItem(name='3月份', max_=320),\n",
    "                opts.RadarIndicatorItem(name='4月份', max_=320),\n",
    "                opts.RadarIndicatorItem(name='5月份', max_=320),\n",
    "                opts.RadarIndicatorItem(name='6月份', max_=320),\n",
    "                opts.RadarIndicatorItem(name='7月份', max_=320),\n",
    "                opts.RadarIndicatorItem(name='8月份', max_=320),\n",
    "                opts.RadarIndicatorItem(name='9月份', max_=320),\n",
    "                opts.RadarIndicatorItem(name='10月份', max_=320),\n",
    "                opts.RadarIndicatorItem(name='11月份', max_=320),\n",
    "                opts.RadarIndicatorItem(name='12月份', max_=320)\n",
    "            ]\n",
    "        )\n",
    "        .add('电影数量/部', [[201,143,176,209,196,244,224,267,248,220,224,216]],           \n",
    "             color='red',           \n",
    "             areastyle_opts = opts.AreaStyleOpts(  #设置填充的属性\n",
    "                 opacity = 0.5,                  \n",
    "                 color='red'                     \n",
    "         ),)\n",
    "        .add('电影票房/亿', [[163,251,45,117,41,88,310,130,240,35,51,262]],# 不保留小数点，数据四舍五入\n",
    "             color='blue',\n",
    "             areastyle_opts = opts.AreaStyleOpts(\n",
    "                 opacity = 0.5,#透明度\n",
    "                 color='blue'\n",
    "         ),)\n",
    "        .set_series_opts(label_opts=opts.LabelOpts(is_show=True))\n",
    "        .set_global_opts(\n",
    "            title_opts=opts.TitleOpts(title='各月份上映电影数量及票房',pos_right= 'center',pos_left= 'center'),\n",
    "            legend_opts=opts.LegendOpts(\n",
    "                orient=\"vertical\", pos_top=\"30%\", pos_left=\"7%\"),)\n",
    "    )\n",
    "    return 各月份电影\n",
    "radar_simple().render(\"各月份电影数量及票房雷达图.html\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 各类型电影数量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "主要类型\n",
       "剧情     569\n",
       "动作     261\n",
       "动画     193\n",
       "古装       1\n",
       "喜剧     419\n",
       "奇幻      38\n",
       "悬疑       1\n",
       "惊悚     265\n",
       "战争      79\n",
       "灾难       7\n",
       "爱情     625\n",
       "科幻      23\n",
       "纪录片     68\n",
       "艺术片     13\n",
       "dtype: int64"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "各类型电影数量 = 最终中国电影数据.groupby('主要类型').size()\n",
    "各类型电影数量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'C:\\\\Users\\\\南极有火山\\\\Desktop\\\\Data-final\\\\各类型电影数量饼图.html'"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 各类型电影数量饼图\n",
    "from pyecharts.faker import Faker\n",
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Page, Pie\n",
    "l1 = [\"剧情\", \"动作\", \"动画\", \"古装\", \"喜剧\", \"奇幻\", \"悬疑\", \"惊悚\", \"战争\", \"灾难\", \"爱情\", \"科幻\", \"纪录片\", \"艺术片\"]\n",
    "num =[569, 261, 193, 1, 419, 38, 1, 265, 79, 7, 625, 23, 68, 13]\n",
    "各类型电影数量饼图 = (\n",
    "        Pie()\n",
    "        .add(\n",
    "            \"\",\n",
    "            [list(z) for z in zip(l1, num)],\n",
    "            radius=[\"40%\", \"65%\"],   # 圆环的粗细和大小\n",
    "        )\n",
    "        .set_global_opts(\n",
    "            title_opts=opts.TitleOpts(title=\"各类型电影数量饼图\",pos_right= 'center',pos_left= 'center'),\n",
    "            legend_opts=opts.LegendOpts(\n",
    "                orient=\"vertical\", pos_top=\"20%\", pos_left=\"20%\"  # 左面比例尺\n",
    "            ),\n",
    "        )\n",
    "        .set_series_opts(label_opts=opts.LabelOpts(formatter=\"{b}: {c}\"))\n",
    "    )\n",
    "各类型电影数量饼图.render_notebook()\n",
    "各类型电影数量饼图.render(\"各类型电影数量饼图.html\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "# plt.figure(figsize=(15.0,10.0))\n",
    "# 各类型电影数量.plot(kind='barh')\n",
    "# plt.savefig('各类型电影数量.png')\n",
    "# plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 各类型电影票房"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "主要类型\n",
       "剧情     158.34148\n",
       "动作     463.49809\n",
       "动画      91.86388\n",
       "古装       0.00080\n",
       "喜剧     489.83895\n",
       "奇幻     128.98918\n",
       "悬疑       0.00012\n",
       "惊悚      37.56842\n",
       "战争      53.76464\n",
       "灾难       1.83294\n",
       "爱情     261.58174\n",
       "科幻      36.69675\n",
       "纪录片      8.07812\n",
       "艺术片      0.09783\n",
       "Name: 票房/万, dtype: float64"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "各类型电影票房 = 最终中国电影数据.groupby('主要类型')['票房/万'].sum()/10000\n",
    "各类型电影票房"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'C:\\\\Users\\\\南极有火山\\\\Desktop\\\\Data-final\\\\各类型电影票房漏斗图.html'"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 各类型电影票房漏斗图\n",
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Funnel, Page\n",
    "from random import randint\n",
    "\n",
    "attr =['剧情', '动作', '动画', '古装', '喜剧', '奇幻', '悬疑', '惊悚', '战争', '灾难', '爱情','科幻','纪录片','艺术片']\n",
    "values =[158,463,92,0,490,129,0,38,54,2,262,37,8,0]  # 不保留小数点，数据四舍五入\n",
    "\n",
    "def funnel_base() -> Funnel:\n",
    "    各类型电影票房 = (\n",
    "        Funnel()\n",
    "        .add(\"天气\", [list(z) for z in zip(attr,values)])\n",
    "        .set_global_opts(\n",
    "            title_opts=opts.TitleOpts(title=\"各类型电影票房漏斗图\",pos_right= 'center',pos_left= 'center',pos_top='5%'),\n",
    "        legend_opts=opts.LegendOpts(\n",
    "                orient=\"vertical\", pos_top=\"30%\", pos_left=\"3%\"  # 左面比例尺\n",
    "            ),)\n",
    "        \n",
    "    )\n",
    "    return 各类型电影票房\n",
    "    \n",
    "funnel_base().render_notebook()\n",
    "funnel_base().render('各类型电影票房漏斗图.html')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [],
   "source": [
    "# plt.figure(figsize=(15.0,10.0))\n",
    "# 各类型电影票房.plot(kind='barh')\n",
    "# plt.savefig('各类型电影票房.png')\n",
    "# plt.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
